package com.heking.widgetlib;

import android.os.Bundle;
import android.widget.Button;
import android.widget.ViewFlipper;

import com.zhoug.common.base.AbsActivity;
import com.zhoug.common.utils.LogUtils;
import com.zhoug.widget.marquee.MarqueeHorizontalTextView;

import androidx.annotation.Nullable;

/**
 * 水平跑马灯
 * @Author 35574
 * @Date 2020/7/2
 * @Description
 */
public class HMarqueeActivity extends AbsActivity {
    private ViewFlipper mViewFlipper;
    private MarqueeHorizontalTextView mMarqueeHorizontalTextView1;
    private MarqueeHorizontalTextView mMarqueeHorizontalTextView2;
    private Button mBtn1;
    private Button mBtn2;

    @Override
    protected int getLayoutResID() {
        return R.layout.activity_h_marquee;
    }

    @Override
    protected void findViews() {
        mViewFlipper = findViewById(R.id.viewFlipper);
        mMarqueeHorizontalTextView1 = findViewById(R.id.marqueeHorizontalTextView1);
        mMarqueeHorizontalTextView2 = findViewById(R.id.marqueeHorizontalTextView2);
        mBtn1 = findViewById(R.id.btn1);
        mBtn2 = findViewById(R.id.btn2);

        mMarqueeHorizontalTextView1.setSpeed(6);
        mMarqueeHorizontalTextView1.setStartModel(MarqueeHorizontalTextView.MODEL_END);

    }

    @Override
    protected void addListener() {
        mBtn1.setOnClickListener(v->{
            mViewFlipper.startFlipping();
            mMarqueeHorizontalTextView1.start();
            mMarqueeHorizontalTextView2.start();
        });
        mBtn2.setOnClickListener(v->{
            mViewFlipper.stopFlipping();
            mMarqueeHorizontalTextView1.stop();
            mMarqueeHorizontalTextView2.stop();
        });
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void onCreateFinish(@Nullable Bundle savedInstanceState) {

    }

    @Override
    protected void onResume() {
        super.onResume();
        mMarqueeHorizontalTextView1.start();
        mMarqueeHorizontalTextView2.start();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mMarqueeHorizontalTextView1.stop();
        mMarqueeHorizontalTextView2.stop();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        LogUtils.d(TAG, "onDestroy:");
    }
}
